#include <stdio.h>

int main(){
    int len;
    if(scanf("%d",&len) != EOF){
        if(len > 0){
            int arr[len];
            for(int i = 0;i < len;i++){
                scanf("%d",&arr[i]);
            }
            int index = 0;
            if(scanf("%d",&index) != EOF){
                if(index >= 0){
                    int sum = 0;
                    if(scanf("%d",&sum) != EOF){
                        while(sum != 0){
                            if(index <= 4){
                                printf("%d\n",arr[index]);
                                index++;
                            }else{
                                index = (index + len - 1);
                                printf("%d\n",arr[index % 5]);
                                index--;
                            }
                            sum--;
                        }
                    }
                }
            }
        }
    }
    return 0;
}